﻿using AutoMapper;
using MediatR;
using ProcurementManagement.Applcation.Command.QualityCommand;
using ProcurementManagement.Domain.ProcurementDomain;
using ProcurementManagement.Infrstructre.Interface;

namespace ProcurementManagement.Applcation.CommandHanlers.QualityCommandHandler
{
    /// <summary>
    /// 采购申请添加
    /// </summary>
    public class CreateQualityCommandHandlers:IRequestHandler<CreateQualityCommand,int>
    {


        private readonly IProPcApplyRepository repository;
        IMapper mapper;

        public CreateQualityCommandHandlers(IProPcApplyRepository repository, IMapper mapper)
        {
            this.repository = repository;
             this.mapper = mapper;
        }

        public Task<int> Handle(CreateQualityCommand request, CancellationToken cancellationToken)
        {
            var query =  mapper.Map<ProPcApply>(request.AddDTo);
            return repository.AddAsync(query);
        }
    }
}
